package com.pagepub.expo.manager;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.flex.remoting.RemotingDestination;
import org.springframework.flex.remoting.RemotingInclude;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.pagepub.expo.dao.AppFunctionDao;
import com.pagepub.expo.dao.AppRoleDao;
import com.pagepub.expo.entity.AppFunction;
import com.pagepub.expo.entity.AppRole;

@Service
@Transactional
@RemotingDestination(channels = { "my-amf", "my-secure-amf" })
public class AppRoleMng {
	@Autowired
	private AppRoleDao roleDao;


	@RemotingInclude
	@Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
	public List<AppRole> findAll() {
		return roleDao.findAll();
	}
	


	
	@RemotingInclude
	@Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
	public int getCount(Map<String, String> param){
		return roleDao.getCount(param);
	}
	
	
	@RemotingInclude
	@Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
	public List<AppRole> findByPage(int currentPage,int pageSize,Map<String, String> param){
		return roleDao.findByPage(currentPage, pageSize, param);
	}


	@RemotingInclude
	public AppRole add(AppRole appRole) {
		roleDao.insert(appRole);
		return roleDao.findById(appRole.getRoleId());
	}

	@RemotingInclude
	public Long remove(Long id) {
		roleDao.delete(id);
		return id;
	}

	@RemotingInclude
	public AppRole update(AppRole appRole) {
		roleDao.update(appRole);
		return roleDao.findById(appRole.getRoleId());
	}
}
